<!doctype html>
<html lang="en">
	<head>
		<!-- Required meta tags -->
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<!-- Bootstrap CSS -->
		<link rel="stylesheet" href="css/bootstrap.min.css">
		<title>图书列表</title>
		<script type="text/javascript">

		</script>
	</head>
  
	<body>
		<h1 class="text-center pt-3 pb-3">图书列表</h1>
		
		<div class="container">
			<div class="offset-md-2 col-md-8">
				<div class="row">
					<div class="col-md-10">
						<form action="/all_books" method="get" class="form-inline">
							<div class="form-group">
								<label>出版社：</label>
								<select class="form-control form-control-sm" name="publisherId">
									<option value="0">所有出版社</option>
									<#list publisherList as p>
										<option value="${p.publisherId}" ${(publisherId == p.publisherId)?string("selected","")}>
											${p.publisherName}
										</option>
									</#list>
								</select>
								&nbsp;&nbsp;
								<button type="submit" class="btn btn-sm btn-outline-secondary">查询</button>
							</div>
						</form>
					</div>
					<div class="col-md-2">
						<form class="form-inline">
							<div class="form-group">
								<#--新开一个窗口显示页面-->
								<button type="button" onclick="window.open('/goto_add')" class="btn btn-sm btn-outline-secondary">
									新增图书
								</button>
							</div>
						</form>
					</div>
				</div>
				
				<hr>

				<table class="table table-bordered">
					<thead>
						<tr>
							<th>图书编号</th>
							<th>图书名称</th>
							<th>出版社</th>
							<th>图书分类</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						<#list allBooks.resultList as b>
							<tr>
                                <td>${b.bookId}</td>
                                <td>${b.bookName}</td>
                                <td>${b.publisher.publisherName}</td>
								<td>
									<#list b.categoryList as c>
										${c.categoryName}
									</#list>
								</td>
                                <td>
                                    <a href="/goto_update?bookId=${b.bookId}" target="_blank">修改</a> /
                                    <a href="">删除</a>
                                </td>
                            </tr>
						</#list>
					</tbody>
				</table>

				<nav class="pb-5 pt-3">
					<ul class="pagination justify-content-center">
						<li class="page-item ${(allBooks.currentPage==1)?string("disabled","")}">
							<a class="page-link" href="/all_books?pageNo=1&publisherId=${publisherId}" tabindex="-1">首页</a>
						</li>

						<#list 1..allBooks.totalPages as i>
							<li class="page-item ${(allBooks.currentPage==i)?string("active","")}">
								<a class="page-link" href="/all_books?pageNo=${i}&publisherId=${publisherId}">${i}</a>
							</li>
						</#list>

						<li class="page-item ${(allBooks.currentPage==allBooks.totalPages)?string("disabled","")}">
							<a class="page-link" href="/all_books?pageNo=${allBooks.totalPages}&publisherId=${publisherId}">末页</a>
						</li>
					</ul>
				</nav>
			</div>
		</div>
	</body>
</html>
